import 'package:schoollifedemo/channel/common/common_channel.dart';
import 'package:schoollifedemo/channel/home/home_channel.dart';
import 'package:schoollifedemo/channel/register/channel_register.dart';

class ChannelService {
  // 工厂方法制作单例
  static late final ChannelService _channelService = ChannelService._internal();

  ChannelService._internal();

  factory ChannelService() => _channelService;

  final ChannelRegister _channelRegister = ChannelRegister();
  CommonChannelFunc? _commonChannelFunc;
  HomeChannelFunc? _homeChannelFunc;

  void init() {
    _channelRegister.init();
    _commonChannelFunc = CommonChannelFunc(_channelRegister);
    _homeChannelFunc = HomeChannelFunc(_channelRegister);
  }

  CommonChannelFunc? getCommonChannelFunc() => _commonChannelFunc;

  HomeChannelFunc? getHomeChannelFunc() => _homeChannelFunc;

  void dispose() {
    _channelRegister.dispose();
  }
}
